package com.qianxing.service.impl;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qianxing.po.TbRouteDataPO;
import com.qianxing.service.TbRouteDataService;
import com.qianxing.mapper.TbRouteDataMapper;
import com.qianxing.vo.RouteDataVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author JasonLong
 * @description 针对表【tb_route_data(路线表)】的数据库操作Service实现
 * @createDate 2023-07-14 00:20:34
 */
@Service
public class TbRouteDataServiceImpl extends ServiceImpl<TbRouteDataMapper, TbRouteDataPO>
        implements TbRouteDataService {

    @Autowired
    private TbRouteDataMapper routeDataMapper;

    @Override
    public List getAll() {
        List<RouteDataVO> routeDataVOS = routeDataMapper.selectList(null).stream().map(m -> {
            RouteDataVO routeDataVO = new RouteDataVO();
            routeDataVO.setRouteTitle(m.getRouteTitle());
            routeDataVO.setRouteData(m.getRouteData());
            //反序列化
            routeDataVO.setRouteImg(JSON.parseArray(m.getRouteImg()));
            routeDataVO.setUserNickname(m.getUserNickname());
            return routeDataVO;
        }).collect(Collectors.toList());
        return routeDataVOS;
    }
}




